10 DEFINT A-Z:DIM S(640,3),M(20,2),BM(16),BN(16),SEL(20):H=2:T=0:SC=0:GAMEOVER=0:DN2=0
11 DIM GF(10):FX=0:FY=0:RANDOMIZE TIMER
20 FOR I=0 TO 14:BM(I)=2^I:NEXT I:BM(15)=&H8000:FOR I=0 TO 15:BN(I)=NOT BM(I):NEXT I
30 M(0,0)=7:S(1,0)=1:S(2,0)=2
40 SCREEN 1:COLOR 0,1:KEY OFF
50 LOCATE 1,1:PRINT "*";:GET (0,0)-(7,7),GF:CLS
51 FOR I=2 TO 9:GF(I)=GF(I) AND &HAAAA:NEXT I
60 LINE (31,19)-(288,180),1,B:LINE (33,21)-(54,26),3,BF:GOSUB 300
70 KEY 15,CHR$(128)+CHR$(72):KEY 16,CHR$(128)+CHR$(75):KEY 17,CHR$(128)+CHR$(77):KEY 18,CHR$(128)+CHR$(80)
80 ON KEY(11) GOSUB 231:ON KEY(12) GOSUB 232:ON KEY(13) GOSUB 233:ON KEY(14) GOSUB 234
90 ON KEY(15) GOSUB 231:ON KEY(16) GOSUB 232:ON KEY(17) GOSUB 233:ON KEY(18) GOSUB 234
100 FOR I=11 TO 18:KEY(I)ON:NEXT I
110 T0#=TIMER:WHILE GAMEOVER=0:K$=INKEY$:IF K$=CHR$(27) THEN GOTO 200
120 T#=TIMER:IF T#-T0#<0.7 THEN GOTO 190
130 T0#=T#:XN=S(H,0):YN=S(H,1):DN=DN2:D=S(H,2)
140 IF (D=0 AND DN=1) OR (D=1 AND DN=0) OR (D=2 AND DN=3) OR (D=3 AND DN=2) THEN DN=D
150 IF DN=0 THEN XN=XN+1 ELSE IF DN=1 THEN XN=XN-1 ELSE IF DN=2 THEN YN=YN-1 ELSE IF DN=3 THEN YN=YN+1
160 IF XN<0 OR XN>31 OR YN<0 OR YN>19 THEN GAMEOVER=1:GOTO 200
170 IF XN=FX AND YN=FY THEN SC=SC+1:GOSUB 400:GOSUB 300 ELSE GOSUB 500:GOSUB 400
190 WEND
200 SCREEN 0:WIDTH 80:CLS:FOR I=11 TO 18:KEY(I)OFF:NEXT I
210 IF GAMEOVER=1 THEN PRINT "Game Over!!!":SOUND 100,2 ELSE IF GAMEOVER=2 THEN PRINT "YOU WIN!!!":SOUND 500,1:SOUND 1000,1
220 PRINT "Your Score:";SC:PRINT "":END
231 DN2=2:RETURN
232 DN2=1:RETURN
233 DN2=0:RETURN
234 DN2=3:RETURN
300 LSEL=0:FOR I=0 TO 19
310 IF M(I,0)<>&HFFFF OR M(I,1)<>&HFFFF THEN SEL(LSEL)=I:LSEL=LSEL+1
320 NEXT I:IF LSEL=0 THEN GAMEOVER=2:RETURN
330 FY=SEL(INT(RND*LSEL)):PS=0:WHILE PS=0:PS=1:FX=INT(RND*20)
340 IF (BM(FX AND 15) AND M(FY,FX\16))<>0 THEN PS=0
350 WEND:PUT (FX*8+32,FY*8+20),GF:SOUND 900,1:RETURN
400 B0=BM(XN AND 15):M0=M(YN,XN\16):IF (B0 AND M0)<>0 THEN GAMEOVER=1:RETURN
410 M(YN,XN\16)=M0 OR B0:S(H,2)=DN:H=H+1:IF H>=640 THEN H=0
420 S(H,0)=XN:S(H,1)=YN:S(H,2)=DN:LINE (XN*8+32,YN*8+20)-(XN*8+39,YN*8+27),0,BF
430 ON DN GOTO 432,433,434
431 LINE (XN*8+31,YN*8+21)-(XN*8+38,YN*8+26),3,BF:RETURN
432 LINE (XN*8+33,YN*8+21)-(XN*8+40,YN*8+26),3,BF:RETURN
433 LINE (XN*8+33,YN*8+21)-(XN*8+38,YN*8+28),3,BF:RETURN
434 LINE (XN*8+33,YN*8+19)-(XN*8+38,YN*8+26),3,BF:RETURN
500 XT=S(T,0):YT=S(T,1):DT=S(T,2)
510 M(YT,XT\16)=M(YT,XT\16) AND BN(XT AND 15)
520 T=T+1:IF T>=640 THEN T=0
530 ON DT GOTO 532,533,534
531 LINE (XT*8+33,YT*8+21)-(XT*8+40,YT*8+26),0,BF:RETURN
532 LINE (XT*8+31,YT*8+21)-(XT*8+38,YT*8+26),0,BF:RETURN
533 LINE (XT*8+33,YT*8+19)-(XT*8+38,YT*8+26),0,BF:RETURN
534 LINE (XT*8+33,YT*8+21)-(XT*8+38,YT*8+28),0,BF:RETURN

